package com.huatai.user.feign;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huatai.common.api.R;
import com.huatai.common.util.BeanUtil;
import com.huatai.user.entity.LoginLog;
import com.huatai.user.entity.User;
import com.huatai.user.service.LoginLogService;
import com.huatai.user.service.UserService;
import com.huatai.user.vo.UserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Objects;

/**
 * @program: ht-system
 * @description: 用户暴露接口
 * @author: songxiude
 * @create: 2023-02-06 10:43
 **/
@RestController
@RequestMapping("/user/feign")
@Api(value = "用户服务暴露接口", tags = "用户服务暴露接口")
public class UserApiController implements UserClient{
	@Autowired
	private UserService userService;

	@Autowired
	private LoginLogService loginLogService;

	@PostMapping("/getUserPermissions")
	@ApiOperation(value = "获取用户权限信息", notes = "获取用户权限信息")
	public R<UserVo> getUserPermissions(@RequestParam("account") String account){
		UserVo userInfo = userService.findUserInfo(account);
		return R.data(userInfo);
	}

	@PostMapping("/saveLoginLog")
	@ApiOperation(value = "保存用户登录记录", notes = "保存用户登录记录")
	public void saveLoginLog(@RequestBody LoginLog loginLog) {
		loginLogService.save(loginLog);
	}
}
